package com.vehiclemanagement.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.vehiclemanagement.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 用户数据访问层
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 根据用户名查询用户
     *
     * @param username 用户名
     * @return 用户对象
     */
    @Select("SELECT * FROM user WHERE username = #{username} AND del_flag = 0")
    User selectByUsername(@Param("username") String username);
    
    /**
     * 检查用户名是否存在
     *
     * @param username 用户名
     * @return 存在数量
     */
    @Select("SELECT COUNT(*) FROM user WHERE username = #{username} AND del_flag = 0")
    int checkUsernameExists(@Param("username") String username);
} 